'use strict';
/**
 * Created by deng on 16-3-4.
 */

angular.module('metalabPartnerApp').factory('Officer', ['$state', '$uibModalStack', '$uibModal'
    , function ($state, $uibModalStack, $uibModal) {
        var officer = {};

        officer.openVerifyModal = function () {
            officer.clearModal();
            var modalInstance = $uibModal.open({
                animation: false,
                openedClass: 'officer',
                size: 'lg dialog-meta-passport',
                templateUrl: 'views/user/officer-verify.html',
                controller: 'OfficerVerify',
                keyboard: true,
                backdrop: 'static'
            });
            $state.go('.', {officer: 'verify'}, {notify: false});
            return modalInstance;
        };

        officer.clearModal = function () {
            $uibModalStack.dismissAll();
            $state.go('.', {officer: undefined}, {notify: false});
        };

        officer.check = function (params) {
            if (params && params.officer) {
                switch (params.officer) {
                    case 'verify':
                        officer.openVerifyModal();
                        break;
                }
            }
        };

        return officer;
    }]);
